<!DOCTYPE html>
<html>
<head>
    <title>计划调整</title>
    #parse("sys/header.html")
</head>
<body>
<div id="rrapp" v-cloak>
    <div v-show="showList">
        <template>
            <Row :gutter="16" style="margin: 3px 0px"></Row>
            <Tabs @on-click="tabsPage" value="weekly" type="card">
                <Tab-Pane label="周计划" name="weekly">
                    <table id="weekly"></table>
                </Tab-Pane>
                <Tab-Pane label="双周计划" name="deWeekly">
                    <table id="deWeekly"></table>
                </Tab-Pane>
                <Tab-Pane label="月计划" name="month">
                    <table id="month"></table>
                </Tab-Pane>
                <Tab-Pane label="季度计划" name="quarter">
                    <table id="quarter"></table>
                </Tab-Pane>
                <Tab-Pane label="半年计划" name="halfYear">
                    <table id="halfYear"></table>
                </Tab-Pane>
                <Tab-Pane label="年计划" name="yearpl">
                    <table id="yearpl"></table>
                </Tab-Pane>
            </Tabs>
        </template>
    </div>
</div>
<script>
    var id = window.location.search.split('?')[1];
    var flg = window.location.search.split('&')[1]
    $(function () {
        $("#weekly").Grid({
            url: '../devplanmainitem/listDev?planId=' + id + '&freRate=1',
            pager: null,
            rowNum: 1000,
            multiselect: false,
            colModel: [
                {label: '工序', name: 'procedure', index: 'DEV_PROCE_NO', width: 60},
                {label: '设备名称', name: 'devName', index: 'DEV_NAME', width: 100},
                {label: '维护部位', name: 'name', sortable: false, width: 50},
                {label: '维护标准', name: 'checkSt', sortable: false, width: 80},
                {label: '日期', name: 'dayNum', hidden: true,},
                {name: 'itemId', key: true, hidden: true}
            ]
        })
        $("#deWeekly").Grid({
            url: '../devplanmainitem/listDev?planId=' + id + '&freRate=2',
            pager: null,
            rowNum: 1000,
            colModel: [
                {label: '工序', name: 'procedure', index: 'DEV_PROCE_NO', width: 60},
                {label: '设备名称', name: 'devName', index: 'DEV_NAME', width: 100},
                {label: '维护部位', name: 'name', sortable: false, width: 50},
                {label: '维护标准', name: 'checkSt', sortable: false},
                {
                    label: '日期', name: 'dayNum', hidden: true
                },
                {
                    label: '日期', name: 'reserve1', width: 70, sortable: false,
                    formatter: function (value, col, row) {
                        return monthtime(row.dayNum, 32)
                    }
                },
                {name: 'itemId', key: true, hidden: true}
            ]
        })
        $("#month").Grid({
            url: '../devplanmainitem/listDev?planId=' + id + '&freRate=3',
            pager: null,
            rowNum: 1000,
            colModel: [
                {label: '工序', name: 'procedure', index: 'DEV_PROCE_NO', width: 60},
                {label: '设备名称', name: 'devName', index: 'DEV_NAME', width: 100},
                {label: '维护部位', name: 'name', sortable: false, width: 50},
                {label: '维护标准', name: 'checkSt', sortable: false},
                {
                    label: '月份', name: 'monthNum', hidden: true,
                    formatter: function (value) {
                        return 1
                    }
                },
                {
                    label: '日期', name: 'dayNum', hidden: true,
                },
                {
                    label: '日期', name: 'reserve1', width: 70, sortable: false,
                    formatter: function (value, col, row) {
                        return monthtime(row.dayNum, 32)
                    }
                },
                {name: 'itemId', key: true, hidden: true}
            ]
        })
        $("#quarter").Grid({
            url: '../devplanmainitem/listDev?planId=' + id + '&freRate=4',
            pager: null,
            rowNum: 1000,
            colModel: [
                {label: '工序', name: 'procedure', index: 'DEV_PROCE_NO', width: 60},
                {label: '设备名称', name: 'devName', index: 'DEV_NAME', width: 100},
                {label: '维护部位', name: 'name', sortable: false, width: 50},
                {label: '维护标准', name: 'checkSt', sortable: false},
                {name: 'monthNum', hidden: true},
                {
                    label: '月份', width: 70, sortable: false,
                    formatter: function (value, col, row) {
                        return monthtime(row.monthNum, 4)
                    }
                },
                {
                    label: '日期', name: 'dayNum', hidden: true,
                },
                {
                    label: '日期', name: 'reserve2', width: 70, sortable: false,
                    formatter: function (value, col, row) {
                        return monthtime(row.dayNum, 32)
                    }
                },
                {name: 'itemId', key: true, hidden: true}
            ]
        })
        $("#halfYear").Grid({
            url: '../devplanmainitem/listDev?planId=' + id + '&freRate=5',
            pager: null,
            rowNum: 1000,
            colModel: [
                {label: '工序', name: 'procedure', index: 'DEV_PROCE_NO', width: 60},
                {label: '设备名称', name: 'devName', index: 'DEV_NAME', width: 100},
                {label: '维护部位', name: 'name', sortable: false, width: 50},
                {label: '维护标准', name: 'checkSt', sortable: false},
                {name: 'monthNum', hidden: true},
                {
                    label: '月份', name: 'reserve1', width: 70, sortable: false,
                    formatter: function (value, col, row) {
                        return monthtime(row.monthNum, 7)
                    }
                },
                {
                    label: '日期', name: 'dayNum', hidden: true
                },
                {
                    label: '日期', name: 'reserve2', width: 70, sortable: false,
                    formatter: function (value, col, row) {
                        return monthtime(row.dayNum, 32)
                    }
                },
                {name: 'itemId', key: true, hidden: true}
            ]
        })
        $("#yearpl").Grid({
            url: '../devplanmainitem/listDev?planId=' + id + '&freRate=6',
            pager: null,
            rowNum: 1000,
            colModel: [
                {label: '工序', name: 'procedure', index: 'DEV_PROCE_NO', width: 60},
                {label: '设备名称', name: 'devName', index: 'DEV_NAME', width: 100},
                {label: '维护部位', name: 'name', sortable: false, width: 50},
                {label: '维护标准', name: 'checkSt', sortable: false},
                {name: 'monthNum', hidden: true},
                {
                    label: '月份', name: 'reserve1', width: 70, sortable: false,
                    formatter: function (value, col, row) {
                        return monthtime(row.monthNum, 13)
                    }
                },
                {name: 'dayNum', hidden: true},
                {
                    label: '日期', name: 'reserve2', width: 70, sortable: false,
                    formatter: function (value, col, row) {
                        return monthtime(row.dayNum, 32)
                    }
                },
                {name: 'itemId', key: true, hidden: true}
            ]
        })
    })
    var vm = new Vue({
        el: '#rrapp',
        data: {
            showList: true,
            title: null,
            day: [],
            dayDom: '',
            weeklyDay: '',

            quarterData: '',
            quarterDay: 1,
            quarterDom: '',

            halfYearData: '',
            halfYearDay: 1,
            halfYearList: [],
            halfYearDom: '',

            yearplData: '',
            yearplDay: 1,
            yearplList: [],
            yearplDom: '',

            weekly: '',
            deWeekly: '',
            quarter: '',
            halfYear: '',
            yearpl: '',
            tabsName: '0',
            title_plan: '',
            devMaintenPlan: {},
            typeList: enumsToList('MAINTENPLAN_TYPE'),//类型
        },
        methods: {
            tabsPage: function (e) {
                vm.tabsName = e
            }
        }
    });
    var monthtime = function (e, n) {
        let str = ''
        if (flg == 'true') {
            str = 'disabled'
        } else {
            str = ''
        }
        let weekly = ''
        for (let i = 1; i < n; i++) {
            if (i == e) {
                weekly += '<option selected class="op" value=' + i + ' >' + i + '</option>'
            } else {
                weekly += '<option class="op" value=' + i + ' >' + i + '</option>'
            }
        }
        let dayDom = '<select ' + str + ' onmousemove="onmousemoves(this)" onchange="weeklypl(this.options[this.options.selectedIndex].value,this)"  class="ivu-input select-dom" placeholder="执行日期" style="width:100px">' +
            weekly +
            '</select>'
        weeklypl = function (val, dom) {
            dom.parentElement.previousElementSibling.innerHTML = val
        }
        return dayDom
    }

    var onmousemoves = function (e) {
        e.parentElement.setAttribute('title', '')
    }

    var getDatas = function () {
        let planItemList = [];
        let tabNames = ['weekly', 'deWeekly', 'month', 'quarter', 'halfYear', 'yearpl'];
        for (let i = 0; i < tabNames.length; i++) {
            let tabPlanItemList = getSelectedRowDatas('#' + tabNames[i]);
            if (tabPlanItemList && tabPlanItemList.length > 0) {
                for (let j = 0; j < tabPlanItemList.length; j++) {
                    planItemList.push(tabPlanItemList[j]);
                }
            }
        }
        return planItemList;
    }
</script>
</body>
<style>
    .select-dom {
        cursor: inherit;
    }
</style>
</html>
